package com.ccys.app.controller;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import com.ccys.db.page.AppPageDto;
import com.ccys.app.service.MemberService;
import com.ccys.app.service.PromoCodeDraftService;
import com.ccys.common.util.StringUtil;
import com.ccys.common.vo.ResponseResultApp;
import com.ccys.db.cache.SysCodeUtil;
import com.ccys.db.cache.UserUtil;
import com.ccys.db.dto.app.getStarted.*;
import com.ccys.db.entity.*;
import com.ccys.db.mapper.*;
import com.ccys.db.vo.app.getStarted.*;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @Author：XLY
 * @Date：2024/1/17 0017
 */

@RestController
@RequestMapping("/getStarted")
@Api(tags = "GetStarted")
public class GetStartedController {


    @Resource
    private TblSupplierMapper mapper;

    @Resource
    private TblMemberDeliveryAddressMapper deliveryAddressMapper;

    @Resource
    private MemberService memberService;

    @Resource
    private PromoCodeDraftService promoCodeDraftService;


    @Resource
    private TblBookingMapper bookingMapper;


    @Resource
    private TblBookingSymptomMapper symptomMapper;


    @Resource
    private TblBookingImageMapper imageMapper;


    @Resource
    private TblBookingMedicationsMapper medicationsMapper;

    @Resource
    private TblMemberMapper memberMapper;


    @Resource
    private TblMemberAllergiesMapper allergiesMapper;


    @Resource
    private TblBookingEmergencyContactMapper emergencyContactMapper;


    @Resource
    private TblPlanBenefitMapper planBenefitMapper;


    @Resource
    private TblPlanBenefitServiceMapper benefitServiceMapper;


    @ApiOperation("GetStarted/1")
    @GetMapping("GetDoctorListV3")
    public ResponseResultApp<GetDoctorListV3Vo> getDoctorListV3(GetDoctorListV3Dto dto) {
        /**
         * 1.Member/GetDoctorListV3通过specilisation_id来区分科室，0是全科
         * 查询医生表，排班表,队列表。如果传入的配套为EAP绑定的增强配套，则只能查询对应eap设置的医生
         * 排序先打todo
         */
        //如果传入的配套为EAP绑定的增强配套，则只能查询对应eap设置的医生
        List<String> eapDoctorIds = mapper.getEapDoctorIds(dto.getProfile_benefit_id());
        dto.setDoctorIds(CollectionUtils.isEmpty(eapDoctorIds) ? null : eapDoctorIds);
        //分页操作
        AppPageDto.startPage();
        List<GetDoctorListV3Vo.DoctorVo> doctorListV3 = mapper.getDoctorListV3(dto);
        PageInfo<GetDoctorListV3Vo.DoctorVo> pageInfo = new PageInfo<>(doctorListV3);
        GetDoctorListV3Vo vo = new GetDoctorListV3Vo();
        vo.setDoctors(doctorListV3);
        // TODO: 2024/1/23 0023 部分字段没处理 排班表,队列表
        //分页处理
        vo.setTotalPage(pageInfo.getPages());
        //处理语言集合
        List<GetDoctorListV3Vo.DoctorLanguageVo> collect = doctorListV3.stream().flatMap(x -> x.getLanguages().stream()).collect(Collectors.toList());
        List<GetDoctorListV3Vo.LanguageFilterVo> languageFilterVos = collect.stream().map(x -> {
            GetDoctorListV3Vo.LanguageFilterVo filterVo = new GetDoctorListV3Vo.LanguageFilterVo();
            filterVo.setId(x.getId());
            filterVo.setLanguage(x.getLanguage());
            return filterVo;
        }).collect(Collectors.toList());
        vo.setLanguageFilters(languageFilterVos);

        return ResponseResultApp.success(vo);
    }


    @ApiOperation("GetStarted/Android/2")
    @GetMapping("GetChildProfileV2")
    public ResponseResultApp getChildProfileV2() {
        String curLoginUserId = UserUtil.getCurLoginUserId();
        
        //age 转换
        List<FamilyVo> family = getFamily(curLoginUserId);
        ChildProfileVo res = new ChildProfileVo();
        res.setChildren(family);
        return ResponseResultApp.success(res);
    }


    @ApiOperation("GetStarted/2")
    @GetMapping("Family")
    public ResponseResultApp<FamilyResVo> family() {

        String curLoginUserId = UserUtil.getCurLoginUserId();
        
        //age 转换
        List<FamilyVo> family = getFamily(curLoginUserId);
        List<FamilyResVo.DependantVo> familyDependants = mapper.getFamilyDependants(curLoginUserId);
        List<FamilyResVo.InviterVo> familyInviters = mapper.getFamilyInviters(curLoginUserId);
        FamilyResVo res = new FamilyResVo();
        res.setChildren(family);
        res.setDependants(familyDependants);
        res.setInviters(familyInviters);
        return ResponseResultApp.success(res);
    }

    private List<FamilyVo> getFamily(String curLoginUserId) {

        //age 转换
        List<FamilyVo> family = mapper.family(curLoginUserId);
        family.forEach(x -> {
            Date dob = x.getDateOfBirth();
            if (Objects.nonNull(dob)) {
                int age = (int) DateUtil.betweenYear(dob, new Date(), false);
                x.setAge(age);
            }

        });
        return family;
    }


    @ApiOperation("GetStarted/3")
    @GetMapping("GetConsultProfile")
    public ResponseResultApp<GetConsultProfileResVo> getConsultProfile(GetConsultProfileDto dto) {
        // TODO: 2024/1/18 0018 deep_link的id,用处不详，打todo
        // 3. Member/GetConsultProfile
        // 查询用户的配套，tbl_plan_benefit_member 配合tbl_plan_benefit_service,
        // 需要获取当用户当前所在国家做第一层筛选。查询参数:child_id(传入时查询当前病人可以给小孩用的配套)
        // ,deep_link(deep_link的id,用处不详，打todo),consult_type(固定传1，感觉没用可以去掉),
        // service_type(1:GP,2:mental wellness,3:pead,8:think well),type(固定0感觉没用),
        // platform_type(固定0感觉没用)
        String curLoginUserId = UserUtil.getCurLoginUserId();
        List<GetConsultProfileVo> consultProfileList = mapper.getConsultProfile(dto.getService_type(), curLoginUserId);
        GetConsultProfileResVo res = new GetConsultProfileResVo();
        res.setProfiles(consultProfileList);
        return ResponseResultApp.success(res);
    }


    @ApiOperation("GetStarted/4")
    @PostMapping("CheckAndRemoveAppliedPromoCode")
    public ResponseResultApp checkAndRemoveAppliedPromoCode() {

        //删除填写的临时promo code,此处还需要开发两个接口，
        // Member/ApplyPromoCode保存临时填写的promo code和Member/GetAppliedPromoCode获取临时填写的promo code
        //使用新增表tbl_promo_code_draft。只有印尼才有此场景，切换至印尼，点击问诊，
        // 在get started页面会有一个promo code输入框，
        // 输入之后会走 Member/ApplyPromoCode添加，
        // 在多处调用Member/GetAppliedPromoCode获取刚才填写的记录
        // ,Member/CheckAndRemoveAppliedPromoCode删除记录
        // update tbl_promo_code_draft set del_flag = 1 where mem_id = #{}
        String curLoginUserId = UserUtil.getCurLoginUserId();
        
        mapper.checkAndRemoveAppliedPromoCode(curLoginUserId);
        return ResponseResultApp.success();
    }

    @ApiOperation("GetStarted/4.1")
    @PostMapping("ApplyPromoCode")
    public ResponseResultApp applyPromoCode(TblPromoCodeDraft model) {
        promoCodeDraftService.insertOrUpdate(model);
        return ResponseResultApp.success();
    }


    @ApiOperation("GetStarted/4.2")
    @GetMapping("GetAppliedPromoCode")
    public ResponseResultApp getAppliedPromoCode() {

        String curLoginUserId = UserUtil.getCurLoginUserId();
        List<TblPromoCodeDraft> draftList = promoCodeDraftService.findListByLimit(TblPromoCodeDraft.class, new ArrayList<String>() {{
            if (StringUtil.isNotEmpty(curLoginUserId)) {
                add("mem_id = '" + curLoginUserId + "'");
            }
            add("del_flag = 0");
        }}, "created_on_utc desc");
        if (CollectionUtils.isNotEmpty(draftList)) {
            return ResponseResultApp.success(draftList.get(0));
        }
        return ResponseResultApp.success();
    }


    @ApiOperation("GetStarted/5")
    @PostMapping("CheckConsultProfile")
    public ResponseResultApp checkConsultProfile(@RequestBody CheckConsultProfileDto dto) {
        /**
         * 传入{
         *     "service_type": "1",//服务类型,同查询profile的接口(1:GP,2:mental wellness,3:pead,8:think well)
         *     "profile_type_id": 2,//这个参数不要了 去掉
         *     "platform_type": 0,//1文本 0视频
         *     "active_code": "",//不要了
         *     "child_id" : "",//选中的childId，为空表示当前账号自己使用
         *     "id": "c4e386c7-bf96-442f-acf0-f329a998e2db"//上一步获取的id 这个应该是指的benefit id
         *     去查 ‘AIA ABSOLUTE CRITICAL COVER’ 和 ‘ys email matching’(这个在direct的福利里面)
         * }
         *
         * 检查这个配套在当前传入的参数中是否可用，主要关联tbl_plan_benefit_service看下是否可用，包括是否过期，
         * benefit for谁，有没有超出额度等,如果可用，返回的message为Success,否则为Error
         */
        String curLoginUserId = UserUtil.getCurLoginUserId();
        
        boolean flag = false;
        //查看这个profile有没有过期
        //这个id是benefitId 还是 benefitServiceId？
        Date currentDate = new Date();
        String profileId = dto.getId();
        TblPlanBenefit tblPlanBenefit = planBenefitMapper.selectByPrimaryKey(profileId);
        if (Objects.nonNull(tblPlanBenefit)) {
            Date endDate = tblPlanBenefit.getEndDate();
            int compare = DateUtil.compare(endDate, currentDate);
            flag = compare >= 0;
        }
        //有没有超过每年最多可报销问诊次数
        TblPlanBenefitService tblPlanBenefitService = benefitServiceMapper.selectByPrimaryKey(profileId);
        if (Objects.nonNull(tblPlanBenefitService)) {
            //每年最多可报销问诊次数
            Integer visitCountLimit = tblPlanBenefitService.getVisitCountLimit();
            //这个benefit是for谁
            String child_id = dto.getChild_id();
            String memId = tblPlanBenefitService.getBenefitForSelf() == 1 || StringUtils.isEmpty(child_id) ? curLoginUserId : child_id;
            //查询今年问诊次数
            //今年时间段
            long startOfYear = DateUtil.beginOfYear(currentDate).getTime();
            long currentTime = currentDate.getTime();
            Integer consultCount = mapper.getConsultCount(memId, profileId, startOfYear, currentTime);
            flag = Objects.nonNull(visitCountLimit) && visitCountLimit > consultCount;
        }
        if (flag) {
            return ResponseResultApp.success();
        } else {
            return ResponseResultApp.error();
        }
    }


    @ApiOperation("GetStarted/6")
    @PostMapping("UpdateLocationDetection")
    public ResponseResultApp updateLocationDetection(@RequestBody UpdateLocationDetectionDto dto) {

        //6.Member/UpdateLocationDetection
        //只修改tbl_member的country_of_residence
        /**
         * 6.Member/UpdateLocationDetection
         * Yes, will update the location in tbl member
         * UPDATE tbl_member SET
         *                 location_address = @PRM_location_address,
         *                 location_country = @PRM_location_country,
         *                 location_postal_code = @PRM_location_postal_code,
         *                 location_latitude = @PRM_location_latitude,
         *                 location_longitude = @PRM_location_longitude,
         *                 location_floor_number = @PRM_location_floor_number,
         *                 location_detail_address = @PRM_location_detail_address,
         *                 location_city =  @PRM_location_city,
         *                 location_state =  @PRM_location_state
         *                 WHERE MEM_ID = @PRM_member_id
         */
        String location_country = dto.getLocation_country();
        TblMember member = new TblMember();
        String curLoginUserId = UserUtil.getCurLoginUserId();
        
        if (StringUtil.isNotEmpty(curLoginUserId)) {
            member.setId(curLoginUserId);
            member.setLocationCountry(location_country);
            member.setLocationAddress(dto.getLocation_address());
            member.setLocationPostalCode(dto.getLocation_postal_code());
            member.setLocationLatitude(dto.getLocation_latitude());
            member.setLocationLongitude(dto.getLocation_longitude());
            member.setLocationFloorNumber(dto.getLocation_floor_number());
            member.setLocationDetailAddress(dto.getLocation_detail_address());
            member.setLocationCity(dto.getLocation_city());
            member.setLocationState(dto.getLocation_state());
            memberService.insertOrUpdate(member);
        }
        return ResponseResultApp.success();
    }


    @ApiOperation("GetStarted/8")
    @PostMapping("CreateDeliveryAddress")
    @Transactional
    public ResponseResultApp createDeliveryAddress(@RequestBody CreateDeliveryAddressDto dto) {

        TblMemberDeliveryAddress model = new TblMemberDeliveryAddress();

        String curLoginUserId = UserUtil.getCurLoginUserId();
        
        model.setIsDefault(dto.is_default() ? 1 : 0);

        model.setMemId(curLoginUserId);

        model.setAddress(dto.getAddress());

        model.setLongitude(dto.getLongitude());

        model.setLatitude(dto.getLatitude());

        model.setFloorNumber(dto.getFloor_number());

        model.setPostalCode(dto.getPostal_code());

        deliveryAddressMapper.insert(model);

        return ResponseResultApp.success("Your address has been successfully added.");
    }

    @ApiOperation("GetStarted/9")
    @PostMapping("PrepareForBooking")
    @Transactional
    public ResponseResultApp prepareForBooking(@RequestBody PrepareForBookingDto model) {

        //查询当前用户是否有status=1并且sub_status=-2并且没删除的booking，有的话就按照传入参数更新，没有的话就创建一条booking，设置status=1,sub_status=-2
        //接收参数如下
        // public class PrepareBooking
        //    {
        //        public string child_id { get; set; }
        //        public string booking_id { get; set; }//应该不会传
        //        public string booking_code { get; set; }//应该不会传
        //        public bool G6PD { get; set; }
        //        public bool pregnant { get; set; }
        //        public List<string> symptoms { get; set; }
        //        public List<dynamic> symptom_photos { get; set; }
        //        public List<dynamic> medications { get; set; }
        //        public List<dynamic> allergies { get; set; }
        //        public List<dynamic> reactions { get; set; }
        //        public string deeplink_id { get; set; }
        //        public List<dynamic> specialist_referral_letter_photos { get; set; }
        //        public int? consult_type { get; set; }
        //        public EmergencyContact emergency_contact { get; set; }
        //        public LocationDetectionModel consulting_from_address { get; set; } = new LocationDetectionModel();
        //        public string mem_delivery_address_id { get; set; }
        //        public int service_type { get; set; }
        //        public string deeplink_identifier_for_tracking { get; set; }
        //    }
        //string account_id, string child_id, string deeplink_id, int consult_type, PrepareBooking model, string timezone
        //booking_bl.PrepareForBooking(accountId, model == null ? "" : model.child_id, model == null ? "" : model.deeplink_id, consult_type, model, Common.GetHeaderValue(Request, Constants.HEADER_TIMEZONE));
        String curLoginUserId = UserUtil.getCurLoginUserId();
        
        String accountId = curLoginUserId;
        String child_id = model.getChild_id();
        String deeplink_id = model.getDeeplink_id();
        //int consult_type = model != null && model.consult_type.HasValue ? model.consult_type.Value : 1;
        Integer consult_type = model.getConsult_type() == null ? 1 : model.getConsult_type();
        // TODO: 2024/1/22 0022 从请求头获取timezone？
        //根据函数API_MemberPrepareForBooking写逻辑
        //1、查询bookingId
        //        SELECT id bookingId
        //        FROM tbl_Booking
        //        WHERE booking_status = 1
        //          AND booking_sub_status = -2
        //          AND mem_id = #{id}
        //          AND child_id = #{child_id}
        //          AND del_flag = 0
        //          AND consult_type=#{consult_type}
        //          and booking_consultation_type=1
        //          and appointment != 1
        Example example = new Example(TblBooking.class);
        example.createCriteria().andEqualTo("status", 1)
                .andEqualTo("subStatus", -2)
                .andEqualTo("memId", accountId)
                .andEqualTo("delFlag", 0)
                .andEqualTo("patientMemId", child_id)
                .andEqualTo("consultType", consult_type)
                .andEqualTo("isAppointment", 0);
        List<TblBooking> bookingList = bookingMapper.selectByExample(example);
        //如果childId有值就取childId为memId
        String memId = StringUtils.isEmpty(child_id) ? accountId : child_id;
        //2、如果没有查到booking数据 就创建一条新的
        String bookingId = "";
        MemberInfoVo memberInfo = mapper.getMemberInfo(memId);
        if (CollectionUtils.isEmpty(bookingList)) {
            // Insert Into tbl_Booking([booking_code], [booking_age], [mem_id], [child_id], [booking_status],
            // [booking_sub_status], booking_created_on , booking_created_on_utc,
            // booking_total_amount, booking_type,Deeplink_Id, consult_type,booking_consultation_type,
            // patient_country_of_residence,currency,booking_time_zone,deeplink_identifier_for_tracking)
            // Values(@PRM_booking_code, @booking_age, @PRM_account_id, @PRM_child_id, 1,
            // -2, [dbo].[fn_Add_Hours](), GETUTCDATE(),
            // 0, 2,@valid_deeplink_id, @PRM_consult_type,
            // 1,@patient_country_of_residence,[dbo].[fn_Get_Currency_Of_Booking_Based_On_Residence](@PRM_account_id),@PRM_timezone,@PRM_deeplink_identifier_for_tracking)
            TblBooking booking = new TblBooking();
            booking.setConsultationNo(IdUtil.getSnowflakeNextIdStr());
            if (Objects.nonNull(memberInfo)) {
                booking.setPatientCountryOfResidence(memberInfo.getCountryOfResidence());
//                booking.setCurrency();
                //currency在bookingsummary里面了
                // TODO: 2024/1/29 0029 Country 的 timezone 格式和bookingtimezone格式不一致
                booking.setBookingTimeZone(memberInfo.getTimeZone() + "");
                Date dob = memberInfo.getDob();
                if (Objects.nonNull(dob)) {
                    int age = (int) DateUtil.betweenYear(dob, new Date(), false);
                    booking.setMemberAge(age);
                }
            }


            booking.setMemId(accountId);
            booking.setPatientMemId(child_id);
            booking.setStatus(1);
            booking.setSubStatus(-2);
            booking.setCreatedOnUtc(new Date().getTime());
            //1adult 2child
            booking.setMemType(StringUtil.isNotEmpty(child_id) ? 2 : 1);
            booking.setDeeplinkId(model.getDeeplink_id());
            booking.setConsultType(consult_type);
            booking.setDeeplinkIdentifierForTracking(model.getDeeplink_identifier_for_tracking());
            bookingMapper.insert(booking);
            bookingId = booking.getId();
        } else {
            bookingId = bookingList.get(0).getId();
        }

        //3、根据bookingId 查询tbl_Booking_Symptoms，tbl_Booking_Image，tbl_Booking_Medications
        // Member,Emergency Contact ,Consulting from address
        //查询tbl_Booking_Symptoms
        Example symptomExample = new Example(TblBookingSymptom.class);
        symptomExample.createCriteria().andEqualTo("bookingId", bookingId);
        List<TblBookingSymptom> symptomList = symptomMapper.selectByExample(symptomExample);
        List<String> symptoms = symptomList.stream().map(TblBookingSymptom::getSymptomId).collect(Collectors.toList());
        model.setSymptoms(symptoms);


        //tbl_Booking_Image
        Example imageExample = new Example(TblBookingImage.class);
        imageExample.createCriteria().andEqualTo("bookingId", bookingId);
        List<TblBookingImage> imageList = imageMapper.selectByExample(imageExample);
        List<PrepareForBookingDto.SymptomPhotoVo> images = imageList.stream().map(x -> {
            PrepareForBookingDto.SymptomPhotoVo vo = new PrepareForBookingDto.SymptomPhotoVo();
            vo.setBooking_image_id(x.getId());
            vo.setImage_name(x.getImageName());
            return vo;
        }).collect(Collectors.toList());
        model.setSymptom_photos(images);

        //tbl_Booking_Medications
        Example medicationExample = new Example(TblBookingMedications.class);
        medicationExample.createCriteria().andEqualTo("bookingId", bookingId);
        List<TblBookingMedications> medicationsList = medicationsMapper.selectByExample(medicationExample);
        List<PrepareForBookingDto.MedicationVo> medications = medicationsList.stream().map(x -> {
            PrepareForBookingDto.MedicationVo vo = new PrepareForBookingDto.MedicationVo();
            vo.setMDMedication_ID(x.getProductId());
            vo.setMDMedicationUsagePeriod_ID(x.getMedicationUsagePeriodId());
            vo.setAmount_of_dosage(x.getAmountOfDosage());
            return vo;
        }).collect(Collectors.toList());
        model.setMedications(medications);

        //member , allergy ,reaction
        Example memberExample = new Example(TblMember.class);
        memberExample.createCriteria().andEqualTo("id", memId);
        TblMember member = memberMapper.selectOneByExample(memberExample);
        if (Objects.nonNull(member)) {
            Integer g6pd = member.getG6pd();
            model.setG6PD(Objects.nonNull(g6pd) && g6pd == 1);
            Integer pregnant = member.getPregnant();
            model.setPregnant(Objects.nonNull(pregnant) && pregnant == 1);
        }


        //allergies
        Example allergyExample = new Example(TblMemberAllergies.class);
        allergyExample.createCriteria().andEqualTo("memId", memId);
        List<TblMemberAllergies> allergyList = allergiesMapper.selectByExample(allergyExample);
        //tbl_booking_medication_reactions是问诊时的过敏的症状，已经整合到上面的过敏表
        //有allergies_name的就是过敏
        List<PrepareForBookingDto.AllergyVo> allergies = allergyList.stream()
                .filter(x -> StringUtils.isNotEmpty(x.getAllergiesName()))
                .map(x -> {
                    PrepareForBookingDto.AllergyVo vo = new PrepareForBookingDto.AllergyVo();
                    //这里已经不存在allergiesid了，直接用allergies_name来当传值
                    vo.setMDAllergies_ID(x.getAllergiesName());
                    return vo;
                }).collect(Collectors.toList());
        model.setAllergies(allergies);

        //reactions
        List<PrepareForBookingDto.ReactionVo> reactionVos = allergyList.stream()
                .filter(x -> StringUtils.isNotEmpty(x.getMedicationReactionId()))
                .map(x -> {
                    PrepareForBookingDto.ReactionVo vo = new PrepareForBookingDto.ReactionVo();
                    vo.setMD_MedicationReaction_ID(x.getMedicationReactionId());
                    return vo;
                }).collect(Collectors.toList());
        model.setReactions(reactionVos);
        //todo referral_letter_photo

        //emergency_contact
        Example contactExample = new Example(TblBookingEmergencyContact.class);
        contactExample.createCriteria().andEqualTo("bookingId", bookingId).andEqualTo("delFlag", 0);
        List<TblBookingEmergencyContact> contactList = emergencyContactMapper.selectByExample(contactExample);
        if (CollectionUtils.isNotEmpty(contactList)) {
            TblBookingEmergencyContact emergencyContact = contactList.get(0);
            PrepareForBookingDto.EmergencyContact vo = new PrepareForBookingDto.EmergencyContact();
            vo.setFirst_name(emergencyContact.getFirstName());
            vo.setLast_name(emergencyContact.getLastName());
            vo.setPhone(emergencyContact.getPhone());
            vo.setRelationship(emergencyContact.getRelationship());
            model.setEmergency_contact(vo);
        }
        //Consulting from address (这个应该是member表里面的吧)
        PrepareForBookingDto.LocationDetectionModel consultAddress = new PrepareForBookingDto.LocationDetectionModel();
        consultAddress.setLocation_address(memberInfo.getLocationAddress());
        consultAddress.setLocation_country(memberInfo.getLocationCountry());
        consultAddress.setLocation_postal_code(memberInfo.getLocationPostalCode());
        consultAddress.setLocation_latitude(memberInfo.getLocationLatitude());
        consultAddress.setLocation_longitude(memberInfo.getLocationLongitude());
        consultAddress.setLocation_floor_number(memberInfo.getLocationFloorNumber());
        consultAddress.setLocation_detail_address(memberInfo.getLocationDetailAddress());
        consultAddress.setLocation_state(memberInfo.getLocationState());
        consultAddress.setLocation_city(memberInfo.getLocationCity());
        return ResponseResultApp.success(model);
    }

    @ApiOperation("Get Started (SP)的Member/GetInfoTogglePHQ4 接口")
    @GetMapping(value = "/GetInfoTogglePHQ4")
    public ResponseResultApp<GetInfoTogglePHQ4Vo> getInfoTogglePHQ4() {
        SysCode code = SysCodeUtil.getCode("Toggle_PHQ4", "2");
        GetInfoTogglePHQ4Vo vo = new GetInfoTogglePHQ4Vo();
        vo.setPhq4(false);
        if (ObjectUtil.isNotEmpty(code.getValue())) {
            vo.setPhq4(code.getValue().equals("true"));
        }
        return ResponseResultApp.success(vo);
    }

}
